package com.cosina.game.crystallight.model;

import android.graphics.Point;
import android.graphics.PointF;

import com.cosina.game.crystallight.engine.util.Time;

public class FlyingStuff implements Time{
	
	public PointF speed;
	public PointF currentLocation;
	private Point to;
	
	public Runnable callback;
	
	public boolean arrive = false;
	public int score ;
	public FlyingStuff(Point from, Point to,int score,Runnable callback){
		this.currentLocation = new PointF(from);
		this.to = to;
		this.score = score;
		float xDistance = to.x - from.x;
		float yDistance = to.y - from.y;
		
		speed = new PointF(xDistance/30,yDistance/30);
		
		this.callback = callback;
	}
	@Override
	public void withTimeGo() {
		currentLocation.offset(speed.x, speed.y);
		
		float xDistance = to.x - currentLocation.x;
		float yDistance = to.y - currentLocation.y;
		
		float distance = PointF.length(xDistance, yDistance);
		if(distance <= 5f){
			arrive = true;
		}
	}
	
}
